#include <iostream>
#include <mutex>
#include <thread>



using namespace std;




mutex m;


void fun(int a)
{
    m.lock();
    cout<<"fun正在改写a"<<endl;
    cout<<"原始为："<<a<<endl;
    cout<<"现在为："<<a+2<<endl;

    m.unlock();
}

void fun1(int a)
{
    m.lock();
    cout<<"fun1正在改写a"<<endl;
    cout<<"原始为："<<a<<endl;
    cout<<"现在为："<<a+1<<endl;
    m.unlock();


}

int main()
{
    int a=0;
    thread th1(fun1,a);
    thread th(fun,a);


    th.join();
    th1.join();

    cout<<"1111111111111"<<endl;
    return 0;
}
